<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript">

    $(function () {

        //toggleOptional();
        $('#area').hide();
        $('#planServeyor').hide();

        $('#planNumber').bind('blur', function () {
            showHidePlanInfo($('#planNumber').val());
        });
        showHidePlanInfo($('#planNumber').val());

        disablePaste(new Array(
                'hectareId',
                'acreId',
                'roodsId',
                'perchesId'
        ));
    });

    function showHidePlanInfo(planNo) {
        if (planNo.length > 0) {
            $('#planServeyor').show();
        } else {
            $('#planServeyor').hide();
        }
    }

    function disableLandInformation() {
        var fields = new Array(
                'districtId',
                'dsDivisionId',
                'gnDivisionId',
                'localAuthorityId',
                'village',
                'nameOfTheLand',
                'planNumber',
                'lotNumber',
                'planDate',
                //'parentLandRefNumber',
                'hectareId',
                'acreId',
                'roodsId',
                'perchesId',
                'northBoundary',
                'northEastBoundary',
                'eastBoundary',
                'southEastBoundary',
                'southBoundary',
                'southWestBoundary',
                'westBoundary',
                'northWestBoundary',
                'northBoundaryType',
                'northEastBoundaryType',
                'eastBoundaryType',
                'southEastBoundaryType',
                'southBoundaryType',
                'southWestBoundaryType',
                'westBoundaryType',
                'northWestBoundaryType',
                'landComment',
                'geologicalTypeId',
                'verifiedByBeneficiarytrue',
                'verifiedByBeneficiaryfalse',
                'areaInWordId',
                'surveyor',
                'purpose',
                'alienationMethodSelectedList-1',
                'alienationMethodSelectedList-2',
                'alienationMethodSelectedList-3',
                'alienationMethodSelectedList-4',
                'alienationMethodSelectedList-5',
                'alienationMethodSelectedList-6',
                'alienationMethodSelectedList-7'
        );
        disableFields(fields);
    }

    $(function () {

        disableLandInformation();
        $("#geoDetails").show();


    });

    function toggleOptional() {
        $('.optional-boundary').toggle();
        $('#show-btn').toggle();
        $('#hide-btn').toggle();
    }

    $(document).ready(function () {
        changeHectareKml();
    });

    ////////////////////////////////////////////////////////////////////////////////////
</script>
<fieldset>
<table class="width-100">
    <tr>
        <s:if test="land.mode.ordinal() == 1">

            <td><s:label value="%{getText('slmsSerialNumber.label')}"/></td>
            <td colspan="3"><s:textfield id="referenceNumber" cssClass="width-200-px" name="tempRefNo"
                                         disabled="true" value="%{land.id}"/></td>

        </s:if>
    </tr>
    <tr>
        <td><s:label value="%{getText('district.label')}"/></td>
        <td><s:textfield id="districtId" name="districtName" cssClass="width-200-px" disabled="true"/></td>
        <td><s:label value="%{getText('ds_division.label')}"/></td>
        <td><s:textfield id="dsDivisionId" name="dsDivisionName" cssClass="width-200-px" disabled="true"/></td>
    </tr>
    <tr>
        <td><s:label value="%{getText('gn_division.label')}"/></td>
        <td>
            <%--<s:if test="viewMode">
                <s:textfield id="gnDivisionId" name="gnDivisionName" cssClass="width-200-px"/>
            </s:if>
            <s:else>
                <s:select id="gnDivisionId" name="land.gnDivision.id" list="gnDivisionList" headerKey="0"
                          headerValue="" cssClass="width-200-px"/>
            </s:else>--%>
            <s:textfield id="gnDivisionId" name="gnDivisionName" cssClass="width-200-px"/>
        </td>
        <td><s:label value="%{getText('local_authority.label')}"/></td>
        <td>
            <s:if test="viewMode">
                <s:textfield id="localAuthorityId" name="land.localAuthority.name" cssClass="width-200-px"/>
            </s:if>
            <s:else>
                <s:select id="localAuthorityId" name="land.localAuthority.id" list="localAuthorityList"
                          cssClass="width-200-px" headerKey="0" headerValue=""/>
            </s:else>
        </td>
    </tr>
    <tr>
        <td><s:label value="%{getText('name_of_the_land.label')}"/></td>
        <td><s:textfield name="land.nameOfTheLand" id="nameOfTheLand" cssClass="width-200-px"/></td>
        <td><s:label value="%{getText('village.label')}"/></td>
        <td><s:textfield name="land.village" id="village" cssClass="width-200-px"/></td>
    </tr>
    <tr>
        <td><s:label value="%{getText('plan_no.label')}"/></td>
        <td><s:textfield name="land.planNumber" id="planNumber" cssStyle="width: 200px;"/></td>
        <td><s:label value="%{getText('lot_no.label')}"/></td>
        <td><s:textfield name="land.lotNumber" id="lotNumber" cssStyle="width: 200px;"/></td>
    </tr>
    <tr id="planServeyor">
        <td><s:label value="%{getText('surveyor.label')}"/></td>
        <td><s:textfield name="land.surveyor" id="surveyor"
                         cssClass="width-200-px"/></td>

        <td><s:label value="%{getText('plan_date.label')}"/></td>
        <td><s:textfield id="planDate" name="land.planDate" cssClass="width-200-px"/></td>
    </tr>
    <tr>
        <td><s:label value="%{getText('geological_type.label')}"/></td>
        <td class="left-align" colspan="3">
            <s:if test="viewMode">
                <s:textfield id="geologicalTypeId" name="land.geologicalType.name" cssClass="width-200-px"/>
            </s:if>
            <s:else>
                <s:select id="geologicalTypeId" name="land.geologicalType.id"
                          list="geologicalTypeList" headerKey="0"
                          headerValue="" cssClass="width-200-px"/>
            </s:else>
        </td>
    </tr>

    <s:if test="land.mode.ordinal() == 1">
        <s:if test="land.geoParcelCode != null">
            <tr>
                <td><s:label value="%{getText('geoParcelCode.label')}"/></td>
                <td colspan="3"><%--<s:label name="land.getGeoParcelCode()"
                        />--%>
                    <s:textfield name="land.getGeoParcelCode()" cssClass="width-200-px"/>
                </td>
            </tr>
        </s:if>


    </s:if>
</table>

<table>
    <tr>
        <td><s:label value="%{getText('extent_of_the_land.label')}"/></td>
        <td colspan="3">
            <table class="width-100">
                <tr>
                    <td><s:label value="%{getText('hectare.label')}"/></td>
                    <td colspan="3"><s:label id="hectareId" name="hectare" cssStyle="width: 80px;" cssClass="bl"
                                             onKeyPress="return numbersonly(event,true)"/></td>

                </tr>

                <tr>
                    <td><s:label value="%{getText('acre.label')}"/></td>
                    <td><s:label id="acreId" name="acre" cssStyle="width: 80px;" cssClass="bl"
                                 onKeyPress="return numbersonly(event,true)"/></td>
                    <td><s:label value="%{getText('roods.label')}"/></td>
                    <td><s:label id="roodsId" name="roods" cssStyle="width: 80px;" cssClass="bl"
                                 onKeyPress="return numbersonly(event,true)"/></td>
                    <td><s:label value="%{getText('perches.label')}"/></td>
                    <td><s:label id="perchesId" name="perches" cssStyle="width: 80px;" cssClass="bl"
                                 onKeyPress="return numbersonly(event,true)"/></td>
                </tr>

                <tr>
                    <td><s:label value="%{getText('hectare_in_word.label')}"/></td>
                    <td colspan="3"><s:textarea id="areaInWordId" name="land.areaInWord" cssClass="width-200-px"
                                                rows="2"/></td>
                </tr>

            </table>
        </td>
    </tr>
    <tr>
        <td><s:label value="%{getText('boundaries.label')}"/></td>
        <td colspan="3">
            <table class="width-100">
                <tr>
                    <td class="width-120-px"><s:label value="%{getText('north.label')}"/></td>
                    <td><s:textarea id="northBoundary" name="land.northBoundary" cssClass="width-250-px" rows="1"/></td>
                    <s:if test="viewMode">
                        <td><s:textfield name="land.northBoundaryType.id" cssClass="width-150-px"
                                         id="northBoundaryType"/></td>
                    </s:if>
                    <s:else>
                        <td><s:select name="land.northBoundaryType.id" cssClass="width-150-px" id="northBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue=""/></td>
                    </s:else>
                </tr>
                <tr>
                    <td><s:label value="%{getText('east.label')}"/></td>
                    <td><s:textarea id="eastBoundary" name="land.eastBoundary" cssClass="width-250-px" rows="1"/></td>
                    <s:if test="viewMode">
                        <td><s:textfield name="land.eastBoundaryType.id" cssClass="width-150-px"
                                         id="eastBoundaryType"/></td>
                    </s:if>
                    <s:else>
                        <td><s:select name="land.eastBoundaryType.id" cssClass="width-150-px" id="eastBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue=""/></td>
                    </s:else>
                </tr>
                <tr>
                    <td><s:label value="%{getText('south.label')}"/></td>
                    <td><s:textarea id="southBoundary" name="land.southBoundary" cssClass="width-250-px" rows="1"/></td>
                    <s:if test="viewMode">
                        <td><s:textfield name="land.southBoundaryType.id" cssClass="width-150-px"
                                         id="southBoundaryType"/></td>
                    </s:if>
                    <s:else>
                        <td><s:select name="land.southBoundaryType.id" cssClass="width-150-px" id="southBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue=""/></td>
                    </s:else>
                </tr>
                <tr>
                    <td><s:label value="%{getText('west.label')}"/></td>
                    <td><s:textarea id="westBoundary" name="land.westBoundary" cssClass="width-250-px" rows="1"/></td>
                    <s:if test="viewMode">
                        <td><s:textfield name="land.westBoundaryType.id" cssClass="width-150-px"
                                         id="westBoundaryType"/></td>
                    </s:if>
                    <s:else>
                        <td><s:select name="land.westBoundaryType.id" cssClass="width-150-px" id="westBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue=""/></td>
                    </s:else>
                </tr>
                <s:if test="!viewMode">
                    <tr class="optional-boundary">
                        <td><s:label value="%{getText('north_east.label')}"/></td>
                        <td><s:textarea id="northEastBoundary" name="land.northEastBoundary" cssClass="width-250-px"
                                        rows="1"/></td>
                        <td><s:select name="land.northEastBoundaryType.id" cssClass="width-150-px"
                                      id="northEastBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue=""/></td>
                    </tr>
                    <tr class="optional-boundary">
                        <td><s:label value="%{getText('south_east.label')}"/></td>
                        <td><s:textarea id="southEastBoundary" name="land.southEastBoundary" cssClass="width-250-px"
                                        rows="1"/></td>
                        <td><s:select name="land.southEastBoundaryType.id" cssClass="width-150-px"
                                      id="southEastBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue=""/></td>
                    </tr>
                    <tr class="optional-boundary">
                        <td><s:label value="%{getText('south_west.label')}"/></td>
                        <td><s:textarea id="southWestBoundary" name="land.southWestBoundary" cssClass="width-250-px"
                                        rows="1"/></td>
                        <td><s:select name="land.southWestBoundaryType.id" cssClass="width-150-px"
                                      id="southWestBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue=""/></td>
                    </tr>
                    <tr class="optional-boundary">
                        <td><s:label value="%{getText('north_west.label')}"/></td>
                        <td><s:textarea id="northWestBoundary" name="land.northWestBoundary" cssClass="width-250-px"
                                        rows="1"/></td>
                        <td><s:select name="land.northWestBoundaryType.id" cssClass="width-150-px"
                                      id="northWestBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue=""/></td>
                    </tr>
                </s:if>


            </table>
        </td>
    </tr>

    <tr>
        <td><s:label value="%{getText('comment_about_land.label')}"/></td>
        <td colspan="3"><s:textarea id="landComment" cssClass="width-595-px"
                                    name="land.landVisitComment" rows="5"/></td>
    </tr>

</table>

<table>
    <s:if test="land.mode.ordinal() == 1 || land.mode.ordinal() == 2">
        <tr><h3><s:label value="%{getText('association_detail.label')}"/></h3></tr>
        <tr>
            <td><s:label value="%{getText('alienation_methods.label')}" cssClass="mandatory-field"/></td>
            <td><s:checkboxlist id="alienationMethodSetId" list="alienationMethodSet"
                                name="alienationMethodSelectedList"
                                value="amSelectedList"
                                theme="checkbox-theme"/></td>


        </tr>

        <tr>
            <td class="left-align"><s:label value="%{getText('association_purpose.label')}"/> :</td>
            <td class="left-align"><s:textarea id="purpose" cssClass="width-450-px"
                                               name="landAssociation.purpose" rows="3"/></td>
        </tr>
    </s:if>
</table>


<%--<table id="geoDetails">
    <s:if test="land.mode.ordinal() == 1">

        <tr id="area">
            <td><s:label value="Area"/></td>
            <td colspan="3"><s:textfield id="kmlArea" cssClass="width-200-px" name="land.kmlLandArea"
                                         readonly="true"/></td>
        </tr>
        <tr>
            <td><s:label value="%{getText('kml_land_extent.label')}"/></td>
            <td colspan="3">
                <table class="width-100">
                    <tr>
                        <td><s:label value="%{getText('hectare.label')}"/></td>
                        <td colspan="5"><s:textfield id="kmlhectareId" name="kmlhectare" cssStyle="width: 80px;"
                                                     readonly="true"/></td>
                    </tr>
                    <tr>
                        <td><s:label value="%{getText('acre.label')}"/></td>
                        <td><s:textfield id="kmlacreId" name="kmlacre" cssStyle="width: 80px;" readonly="true"/></td>
                        <td><s:label value="%{getText('roods.label')}"/></td>
                        <td><s:textfield id="kmlroodsId" name="kmlroods" cssStyle="width: 80px;" readonly="true"/></td>
                        <td><s:label value="%{getText('perches.label')}"/></td>
                        <td><s:textfield id="kmlperchesId" name="kmlperches" cssStyle="width: 80px;"
                                         readonly="true"/></td>
                    </tr>
                </table>
            </td>
        </tr>
        <s:include value="../map.jsp"/>

    </s:if>
</table>--%>
<table>
    <s:if test="documentList != null">
        <tr>
            <td colspan="4">
                <table id="document-list" class="document-list">
                    <s:iterator status="status" value="documentList">
                        <tr id="<s:property value="%{'row' + (#status.count-1)}"/>">
                            <td class="document-icon">
                                <img src="${pageContext.request.contextPath}/images/detailed-form.png"/>
                            </td>
                            <td class="document-type">
                                <s:if test="documentCategory!=null">
                                    <s:property value="documentCategory.categoryName"/>
                                </s:if>

                            </td>

                            <td class="document-download">
                                <s:url action="downloadFile" id="download">
                                    <s:param name="documentId"><s:property value="id"/></s:param>
                                </s:url>
                                <s:a href="%{download}" title="%{getText('download.label')}"><s:label
                                        value="%{documentName}"/><img
                                        src="${pageContext.request.contextPath}/images/download.png"></s:a>
                            </td>

                        </tr>
                    </s:iterator>
                </table>
            </td>
        </tr>
    </s:if>
</table>

</fieldset>
<s:hidden id="landId" name="land.id"/>
<s:hidden name="land.alienationState"/>
<s:hidden id="landMode" name="land.mode"/>
<s:hidden name="land.parentId"/>
<s:hidden id="initRecord" name="land.initialRecordId"/>
<s:hidden name="land.comment"/>
<s:hidden id="approvalState" name="land.approvalState"/>
<s:hidden id="dsDivisionId" name="dsDivisionId"/>
<s:hidden id="landExtent" name="land.landExtent"/>
<s:hidden id="kmlLandArea" name="land.kmlLandArea" disabled="true"/>

<s:hidden id="pls_select_gnDivision" value="%{getText('pls_select_gnDivision.label')}"/>
